// VedioPlayerLoginDlg.cpp

#include "stdafx.h"
#include "VedioPlayer.h"
#include "VedioPlayerLoginDlg.h"
#include "afxdialogex.h"

VedioPlayerLoginDlg* VedioPlayerLoginDlg::m_pVPLoginDlg = nullptr;

IMPLEMENT_DYNAMIC(VedioPlayerLoginDlg, CDialogEx)
BEGIN_MESSAGE_MAP(VedioPlayerLoginDlg, CDialogEx)
END_MESSAGE_MAP()

VedioPlayerLoginDlg::VedioPlayerLoginDlg(CWnd* pParent/* = NULL*/)
    : CDialogEx(VedioPlayerLoginDlg::IDD, pParent)
{
}

VedioPlayerLoginDlg::~VedioPlayerLoginDlg()
{
}

void VedioPlayerLoginDlg::UnInitialize()
{
    if (m_pVPLoginDlg)
    {
        delete m_pVPLoginDlg;
        m_pVPLoginDlg = nullptr;
    }
}

void VedioPlayerLoginDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}

VedioPlayerLoginDlg* VedioPlayerLoginDlg::GetInstance(CWnd* pParent/* = NULL*/)
{
    if (m_pVPLoginDlg == nullptr)
    {
        m_pVPLoginDlg = new VedioPlayerLoginDlg(pParent);
    }

    return m_pVPLoginDlg;
}

BOOL VedioPlayerLoginDlg::PreTranslateMessage(MSG* pMsg)
{
    if(pMsg->message==WM_KEYDOWN)
    {
        if((pMsg->wParam == VK_RETURN) || (pMsg->wParam == VK_ESCAPE))
        {
            UnInitialize();

            return true;
        }
    }

    return CDialogEx::PreTranslateMessage(pMsg);
}

BOOL VedioPlayerLoginDlg::IsInitialize()
{
    if (m_pVPLoginDlg == nullptr)
    {
        return FALSE;
    }

    return TRUE;
}

void VedioPlayerLoginDlg::SetCloseCallBack(CLOSE_CLIENT_DIALOG_CALLBACK callbackCloseDialog)
{
    m_callbackCloseDialog = callbackCloseDialog;
}
